package com.lei.android.videoline.VideoLineView;

import java.util.TimeZone;

/**
 * Author LEI
 * Date 2019/10/24 9:52
 * Description
 */
public class VideoInfo {
    /**
     * 开始时间 yyyy-MM-dd HH:mm:ss
     */
    private String startTime;
    private long startTimeMillis;
    /**
     * 结束时间 yyyy-MM-dd HH:mm:ss
     */
    private String endTime;
    private long endTimeMillis;
    /**
     * 事件类型
     */
    private int eventType;
    public static final int EVENT_TYPE_NONE = 0; // 没有任何事件
    public static final int EVENT_TYPE_STRANGER_IN = 1; // 陌生人闯入
    public static final int EVENT_TYPE_MONITORING_ITEMS = 2; // 物品监控
    public static final int EVENT_TYPE_RECOGNIZE_FACES = 3; // 识别到人脸

    public VideoInfo(String startTime, String endTime, int eventType) {
        this.startTime = startTime;
        this.endTime = endTime;
        this.eventType = eventType;
        this.startTimeMillis = VideoLineDateUtils.string2LongTime(startTime, "yyyy-MM-dd HH:mm:ss");
        this.endTimeMillis = VideoLineDateUtils.string2LongTime(endTime, "yyyy-MM-dd HH:mm:ss");
    }

    public VideoInfo(long startTimeMillis, long endTimeMillis, int eventType) {
        // 由于本地时间轴，按照默认时区绘制，所以将固件UTC时区转换一下
        this.startTime = VideoLineDateUtils.long2StringTime(startTimeMillis, "yyyy-MM-dd HH:mm:ss", TimeZone.getTimeZone("UTC"));
        this.endTime = VideoLineDateUtils.long2StringTime(endTimeMillis, "yyyy-MM-dd HH:mm:ss", TimeZone.getTimeZone("UTC"));
        this.eventType = eventType;
        this.startTimeMillis = VideoLineDateUtils.string2LongTime(startTime, "yyyy-MM-dd HH:mm:ss");
        this.endTimeMillis = VideoLineDateUtils.string2LongTime(endTime, "yyyy-MM-dd HH:mm:ss");
    }

    public void setEndTimeMillis(long endTimeMillis) {
        this.endTimeMillis = endTimeMillis;
        this.endTime = VideoLineDateUtils.long2StringTime(startTimeMillis, "yyyy-MM-dd HH:mm:ss");
    }

    public long getStartTimeMillis() {
        return startTimeMillis;
    }

    public long getEndTimeMillis() {
        return endTimeMillis;
    }

    public int getEventType() {
        return eventType;
    }

    /**
     * 获取对应类型在视频时间刻度尺上的颜色
     * <p>
     * 00%=FF（不透明）
     * 5%=F2
     * 10%=E5
     * 15%=D8
     * 20%=CC
     * 25%=BF
     * 30%=B2
     * 35%=A5
     * 40%=99
     * 45%=8c
     * 50%=7F
     * 55%=72
     * 60%=66
     * 65%=59
     * 70%=4c
     * 75%=3F
     * 80%=33
     * 85%=21
     * 90%=19
     * 95%=0c
     * 100%=00（全透明）
     *
     * @return
     */
    public int getEventColor() {
        if (eventType == EVENT_TYPE_NONE) {
            return 0x8C4DD0D2;
        } else if (eventType == EVENT_TYPE_STRANGER_IN) {
            return 0x8CF85555;
        } else if (eventType == EVENT_TYPE_MONITORING_ITEMS) {
            return 0x8CFAB619;
        } else if (eventType == EVENT_TYPE_RECOGNIZE_FACES) {
            return 0x8C4DD0D2;
        } else {
            return 0x00000000;
        }
    }

}
